package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * @author 经销商
 * @version v1.0
 * @date 2020/12/21 10:44
 * @desrcption 经销商的菜单内容
 * @since v1.0
 */
@Getter
public enum MarketingManagementMenuEnum {

    //营销管理

    MARKETING_TOOL(XbbRefTypeEnum.MARKETING_TOOL.getName(), XbbRefTypeEnum.MARKETING_TOOL.getAlias(),
            XbbRefTypeEnum.MARKETING_TOOL.getCode(), AccessLinkEnum.MARKETING_TOOL,  "", MenuTypeEnum.GROUP.getType()),

    MARKETING_ACTIVITY(XbbRefTypeEnum.MARKETING_ACTIVITY.getName(), XbbRefTypeEnum.MARKETING_ACTIVITY.getAlias(),
            XbbRefTypeEnum.MARKETING_ACTIVITY.getCode(), AccessLinkEnum.MARKETING_ACTIVITY,  XbbRefTypeEnum.MARKETING_TOOL.getAlias(), MenuTypeEnum.MENU.getType()),

    MARKETING_ACTIVITY_MANAGEMENT(XbbRefTypeEnum.MARKETING_ACTIVITY_MANAGEMENT.getName(), XbbRefTypeEnum.MARKETING_ACTIVITY_MANAGEMENT.getAlias(),
            XbbRefTypeEnum.MARKETING_ACTIVITY_MANAGEMENT.getCode(), AccessLinkEnum.MARKETING_ACTIVITY_MANAGEMENT,  XbbRefTypeEnum.MARKETING_TOOL.getAlias(), MenuTypeEnum.MENU.getType()),

    PROMOTION_TOOL(XbbRefTypeEnum.PROMOTION_TOOL.getName(), XbbRefTypeEnum.PROMOTION_TOOL.getAlias(),
            XbbRefTypeEnum.PROMOTION_TOOL.getCode(), AccessLinkEnum.PROMOTION_TOOL,  "", MenuTypeEnum.GROUP.getType()),

    PROMOTION_ACTIVITY(XbbRefTypeEnum.PROMOTION_ACTIVITY.getName(), XbbRefTypeEnum.PROMOTION_ACTIVITY.getAlias(),
            XbbRefTypeEnum.PROMOTION_ACTIVITY.getCode(), AccessLinkEnum.PROMOTION_ACTIVITY,  XbbRefTypeEnum.PROMOTION_TOOL.getAlias(), MenuTypeEnum.MENU.getType()),

    PROMOTION_ACTIVITY_MANAGEMENT(XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getName(), XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getAlias(),
            XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getCode(), AccessLinkEnum.PROMOTION_ACTIVITY_MANAGEMENT,  XbbRefTypeEnum.PROMOTION_TOOL.getAlias(), MenuTypeEnum.MENU.getType()),


    ;

    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     * @see XbbRefTypeEnum
     */
    private String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private Integer code;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private String parent;

    /**
     * 类型
     * @see MenuTypeEnum
     */
    private Integer type;


    MarketingManagementMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, Integer type){
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.type = type;
    }

    public static MarketingManagementMenuEnum getByAlias(String alias) {
        for(MarketingManagementMenuEnum crmMenuEnum: values()) {
            if(crmMenuEnum.getAlias().equals(alias)){
                return crmMenuEnum;
            }
        }
        return null;
    }

    public static MarketingManagementMenuEnum getByCode(Integer code) {
        for(MarketingManagementMenuEnum crmMenuEnum: values()) {
            if(crmMenuEnum.getCode().equals(code)){
                return crmMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
